package com.wasion.pwportable.protocol.analyzer.indicator;

import com.wasion.pwportable.protocol.analyzer.AbstractAnalyzer;

/**
 * 
 * @ClassName: RelayInfo_RD_Analyzer
 * @Description: 6C. 节点中继相关信息（架空、用于现场掌机单点操作）
 * @author 高意
 * @date 2014-9-11 上午8:33:57
 * 
 */
public class RelayInfo_RD_Analyzer extends AbstractAnalyzer {

	@Override
	public void dataAnalysis(String ackBS) {

		String data = ackBS.substring(DATABITSTART, DATABITSTART + 24);

		String devIdD = data.substring(4, 6) + data.substring(2, 4)
				+ data.substring(0, 2);
		result.setNeighbor1(devIdD);

		devIdD = data.substring(10, 12) + data.substring(8, 10)
				+ data.substring(6, 8);
		result.setNeighbor2(devIdD);

		devIdD = data.substring(16, 18) + data.substring(14, 16)
				+ data.substring(12, 14);
		result.setParent(devIdD);

		int relay = Integer.parseInt(data.substring(18, 20), 16);
		result.setMaxRelayLevel(relay);

		relay = Integer.parseInt(data.substring(20, 22), 16);
		result.setCurrRelayLevel(relay);

		String phase = (Integer.parseInt(data.substring(22, 24), 16) & 0x03)
				+ "";

		result.setPhase(phase);
	}
}
